The Debugger is a convenient and efficient way to test or follow the processing of any logic defined in your model. The debugger is used to step through logic one statement at a time and examine variables and attributes while a model is running.
Before discussing the details of the Debug option, it is important to understand the following terms:
Statement A statement causes
Logic Logic refers to the complete set of statements defined for a particular process record, downtime event, initialization logic, or termination logic for a simulation.
Thread A thread is a specific execution of any logic. A thread is initiated whenever a logic needs to be executed. This can be an entity running through an operation logic, the initialization logic, a resource running a node logic, a downtime logic, or any other logic. Note that the same logic may be running in several threads at the same time. For example, three entities of the same type being processed simultaneously at the same multi-capacity location would constitute three threads.
A thread or logic execution can be suspended by any statement, causing simulation time to pass (e.g., GET Res1, WAIT 5, etc.). After such a statement completes its task, the thread is resumed. During the time a thread is suspended, other threads may be initiated, suspended, resumed, or completed. This is called thread switching.
Please Note: Even though several threads can execute the same logic at the same time in the simulation, the simulation processor can only process them one at a time. So there is really only one current thread while all other threads are suspended (either scheduled for some future simulation time, or waiting to be executed after the current thread at the same simulation instant).
To better explain the above concepts, consider the following operation logic for a multi-capacity location.
In general, for a logic block containing statements that pass simulation time, any number of threads can wait for the required simulation time to elapse, corresponding to each time elapsing statement. These threads are scheduled to resume at some future simulation time.
There can also be many threads (any number of threads corresponding to each of the time elapsing statements within the logic) which have completed their waiting time, but await their turn to continue execution. These threads are on hold because the simulation engine is busy with another thread scheduled for the same simulation time. There is only one thread executed at any real time instant by the simulation engine.
The debugger window will display a unique identification number for the current, active thread. This thread ID number will help you differentiate between different instances of the same logic block while you are debugging your models.
The Debugger Options dialog box allows the user to specify when to display the Debugger dialog box during the simulation run.
Disable debugger Disables the debugger completely. By default the debugger is enabled. Running the model with the debugger disabled increases the run speed. When running multiple replications or scenarios, or when the animation is disabled, the debugger will automatically be disabled.
DEBUG statement Displays the Debugger dialog box every time a DEBUG statement is encountered in an enabled process while running the simulation. See Debug for more information.
Global Change Displays the Debugger dialog box every time a global change occurs to a specified variable or array. The Debugger dialog box shows the original and new value of the element. Only one global name can be specified in this box.
User Condition Displays the Debugger dialog box when a defined user condition written as a Boolean expression becomes true, for example, when Var1=5. Only one expression can be specified in this box, although several conditions can be tested by using the OR operator. See Boolean Expressions for more information.
Check Condition Allows the user to define how often to check the user condition. The options include:
Debug button Pressing the Debug button displays the Debugger dialog box before the next statement executes.
OK Closes the Debugger Options dialog box and continues to run the simulation model.
The Debugger can be used in two modes: Basic and Advanced. The Basic Debugger appears initially with the option of using the Advanced Debugger. The Basic Debugger dialog box is shown below:
Error Display Box Displays the error message or reason why the Debugger dialog box is displayed, such as the User-Condition becoming true.
Logic Display Box Displays the statements of the current logic being executed.
Context Box Displays the module, operation, and line number (in which the debugger stopped) in the Information box.
Information Box Displays local variables and entity attributes with non-zero values in the Information box.
End Simulation Choose this option to terminate the simulation. This will prompt you about collecting statistics.
Run Continues to run the simulation, but still checks the debugger options selected in the Debugger Options dialog box.
Next Statement Jumps to the next statement in the current thread. If the last statement executed suspends the thread (e.g., the entity is waiting to capture a resource), another thread meeting the debugger conditions may be displayed as the next statement.
Next Thread Brings up the Debugger at the next initiated or resumed thread.
Into Subroutine Steps to the first statement in the next subroutine executed by this thread. Again, if the last statement executed suspends the thread, another thread meeting debugger conditions may be displayed first. If no subroutine is found in the current thread, a message is displayed in the Error Display box.
Options Brings up the Debugger Options dialog box. You may also bring up this dialog box from the Simulation menu.
Advanced Changes the Debugger to Advanced mode, provides additional options discussed next.
The Advanced Debugger contains all options in the Basic Debugger plus a few advanced features.
Next (Thread) Jumps to the next initiated or resumed thread. This button has the same functionality as the Next Thread button in the Basic debugger.
New (Thread) Jumps to the next initiated thread.
Disable (Thread) Temporarily disables the debugger for the current thread (see also enable).
Exclusive (Thread) The debugger displays the statements executed within the current thread only. When the thread terminates, the exclusive setting is removed.
Next (Logic) Jumps to the next initiated or resumed thread that is not executing the same logic as the current thread.
New (Logic) Jumps over any resumed threads to the next initiated thread not executing the same logic as the current thread.
Disable (Logic) Temporarily disables the debugger for all threads executing the current logic (see also enable).
Exclusive (Logic) The debugger displays only the statements executed in any thread executing the current logic.
Enable disabled threads and logics Enables the threads and logics which were disabled previously.
A simulation model demonstrates a proposed acute care clinic. A variable, Census, is used to track the number of patients in the clinic at any one time. Suppose we want to display the Debugger when the variable, Census, reaches a value of 10. We could place an IF...THEN statement, including DEBUG, after the statement incrementing the variable, Census, as shown below:
By checking the box next to the DEBUG statement in the Debugger Options dialog, the Debugger is displayed when the variable, Census, reaches 10.
Suppose we want to know when the variable, COUNT, is incremented. We would check the box to the left of Global Change and type COUNT in the Global Change field. This will display the Debugger dialog box each time COUNT changes. It will also display the previous and changed value of COUNT.
Suppose we want to follow a
Debugger syntax
WAIT N(5,3)
INC Var1
...
...
...
© 2012 ProModel Corporation • 556 East Technology Avenue • Orem, UT 84097 • Support: 888-776-6633 • www.promodel.com |